package online.heycm;

import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.font.PDType1Font;

import java.io.File;

/**
 * @author hey
 * @version 1.0
 * @since 2024-8-16 20:42:19
 */
public class Demo {

    public static void main(String[] args) {
        String filePath = "D:\\code\\aaaa.pdf";
        String savePath = "D:\\code\\bbbb.pdf";

        PDF pdf = new PdfPath(filePath, savePath);
        pdf.load();
        pdf.switchPage(0);
        pdf.setFont(PDType1Font.HELVETICA_BOLD, 12);
        for (int i = 0; i < 10; i++) {
            pdf.appendText(100, 100 + 20 * i, "Hello World! ---- " + i);
        }
        pdf.save();
        pdf.close();



        File font = new File("c:/windows/fonts/simhei.ttf");
        try (PDF pdf1 = new PdfFile(new File(savePath))) {
            pdf1.load();
            pdf1.addPage(PDRectangle.A4);
            pdf1.switchPage(1);
            pdf1.setFont(font, 16);
            pdf1.appendText(100, 700, "众里寻他千百度");
            pdf1.appendText(100, 650, "蓦然回首");
            pdf1.appendText(100, 600, "那人却在灯火阑珊处");
            pdf1.save();
        }
    }
}
